package team.sun.sss.dao.log;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.sun.sss.pojo.log.BreakRule;

import java.util.List;
import java.util.Map;
@Mapper
@Repository
public interface BreakRuleDao {
    @Select("select * from break_rule,student where break_rule.stu_id = student.stu_id order by bre_time desc")
    List<Map<String,Object>> getBreakRuleList();

    @Select("select * from break_rule where bre_id = #{bre_id}")
    List<Map<String,Object>> getBreakRuleListOfBreId(int bre_id);

    @Select("select * from break_rule,student where break_rule.stu_id = student.stu_id")
    List<BreakRule> getBreakRuleList1();

    @Insert("insert into break_rule(stu_id,bre_type,bre_level,bre_type_name,bre_detail,bre_time,bre_relieve_time,bre_operator) " +
            "values(#{stu_id},#{bre_type},#{bre_level},#{bre_type_name},#{bre_detail},#{bre_time},#{bre_relieve_time},#{bre_operator})")
    int addBreakRule(int stu_id, String bre_type, String bre_level, String bre_type_name, String bre_detail, String bre_time, String bre_relieve_time, String bre_operator);

    @Update("update break_rule set bre_type = #{bre_type},bre_level = #{bre_level},bre_type_name = #{bre_type_name},bre_time = #{bre_time},bre_relieve_time = #{bre_relieve_time},bre_detail = #{bre_detail} where bre_id = #{bre_id}")
    int updateBreak(String bre_type, String bre_level, String bre_type_name, String bre_time, String bre_relieve_time, String bre_detail, int bre_id);

    @Delete("delete from break_rule where bre_id = #{bre_id}")
    int Break_delete(@Param("bre_id") int id);

    @Select("select * from break_rule,student where student.stu_id = break_rule.stu_id and break_rule.stu_id=#{stu_id}")
    List<Map<String,Object>> getStuBreakList(@Param("stu_id") int stu_id);

    @Select("select * from break_rule,student where student.stu_id = break_rule.stu_id and (#{stu_name} is null OR stu_name=#{stu_name})" +
            " and (#{stu_college} is null OR stu_college=#{stu_college}) and (#{stu_major} is null OR stu_major=#{stu_major}) order by bre_time desc")
    List<Map<String,Object>> getStuBreakList1(String stu_name,String stu_college,String stu_major);

    @Update("update break_rule set bre_state = 1 where bre_id=#{bre_id}")
    int Break_Up(@Param("bre_id") int bre_id);
}
